/*-----------------------------------------------------------------------------
-- Archivo:                         test_lu.c
-- Fecha de creacion:               13/01/2011
-- Ultima fecha de modificacion:    28/01/2011
-- Diseñador:                       Liliana Andrade
-- Diseño:                          test_lu
-- Proposito:                       Generar estimulos de prueba para la LU con
--                                  el fin de comprobar el resultado de 4 bits
--                                  generado para cada operacion aplicada
-----------------------------------------------------------------------------*/

#include <stdio.h>
#include "genpat.h"

char* inttostr(int entier) {
    char* str;
    str = (char *) mbkalloc (32 * sizeof(char));
    sprintf(str,"%d",entier);
    return(str);
}

main() {
 
    DEF_GENPAT("test_lu");

    DECLAR("A_i"  ,":2","X", IN , "3 downto 0", "");
    DECLAR("B_i"  ,":2","X", IN , "3 downto 0", "");
    DECLAR("CLK"   ,":2","B", IN , ""          , "");
    DECLAR("ALU_OP_i",":2","X", IN , "3 downto 0", "");
    DECLAR("LU_o",":2","X", OUT, "3 downto 0", "");

    DECLAR("vdd"   ,":2","B", IN , ""          , "");
    DECLAR("vss"   ,":2","B", IN , ""          , "");

    LABEL("lu");
  
    SETTUNIT("ns");

    AFFECT("0", "A_i"  , "0"   );
    AFFECT("0", "B_i"  , "0"   );
    AFFECT("0", "CLK"   , "1"   );
    AFFECT("0", "ALU_OP_i", "0"   );

    AFFECT("0", "vdd"   , "1"   ); 
    AFFECT("0", "vss"   , "0"   );

    AFFECT("+25", "CLK"   , "0"  );

    AFFECT("+0" , "A_i"  , "0xC"); /* 12 */
    AFFECT("+0" , "B_i"  , "0xA"); /* 10 */
    AFFECT("+0" , "ALU_OP_i", "0x0");

    AFFECT("+25", "CLK"   , "1"  );

    AFFECT("+25", "CLK"   , "0"  );

    AFFECT("+25", "CLK"   , "1"  );

    AFFECT("+25", "CLK"   , "0"  );

    AFFECT("+25", "CLK"   , "1"  );

    AFFECT("+25", "CLK"   , "0"  );

    AFFECT("+25", "CLK"   , "1"  );

    AFFECT("+0" , "ALU_OP_i", "0x0");

    AFFECT("+25", "CLK"   , "0"  );

    AFFECT("+25", "CLK"   , "1"  );

    AFFECT("+0" , "ALU_OP_i", "0x1");

    AFFECT("+25", "CLK"   , "0"  );

    AFFECT("+25", "CLK"   , "1"  );

    AFFECT("+0" , "ALU_OP_i", "0x2");

    AFFECT("+25", "CLK"   , "0"  );

    AFFECT("+25", "CLK"   , "1"  );

    AFFECT("+0" , "ALU_OP_i", "0x3");

    AFFECT("+25", "CLK"   , "0"  );

    AFFECT("+25", "CLK"   , "1"  );

    AFFECT("+0" , "ALU_OP_i", "0x0");
    
    // AND --> 1000 = 8
    // OR  --> 1110 = E
    // XOR --> 0110 = 6
    // NOT --> 0011 = 3

    SAV_GENPAT();

    exit(0);
}
